import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta:{
      title:"主页"
    }
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
    meta:{
      title:"剪切测试"
    }
  },
  {
    path: '/test',
    name: 'TestHome',
    component: ()=>import('@/views/test/TestHome.vue'),
    meta:{
      title:"用法测试"
    },
    children:[
      {
        path: '/test/notation',
        name: 'TestNotation',
        component: ()=>import('@/views/test/TestNotation.vue'),
        meta:{
          title:"粗略符号使用"
        }
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});
export default router
